#pragma once
#pragma once
#ifndef _CENTROID_TRACKING_H_
#define _CENTROID_TRACKING_H_

#include <unordered_map>
#include <vector>
#include <opencv2/opencv.hpp>

class TrackingResult {
public:
	std::unordered_map<int, cv::Point> objects;
	std::unordered_map<int, int> disappeared;
	std::unordered_map<int, int> frameCount;
	std::unordered_map<int, cv::Point> dxdy;
	std::unordered_map<int, cv::Rect> outrects;
};

class CentroidTracking {
public:
	CentroidTracking(int maxDisappeared = 50, double distanceThreshold = 100);

	void registerObject(const cv::Point& centroid, const cv::Rect& rect);
	void dergisterObject(int objectID);
	TrackingResult update(const std::vector<cv::Rect>& rects);



private:
	int maxDisappeared;
	int nextObjectId;
	double distanceThreshold;
	std::unordered_map<int, cv::Point> objects;
	std::unordered_map<int, int> disappeared;
	std::unordered_map<int, int> frameCount;
	std::unordered_map<int, cv::Point> dxdy;
	std::unordered_map<int, cv::Rect> outrects;
};

#endif  // CENTROID_TRACKING_H
